home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / misc / emu / arosdev.lha / AROS / rom / utility / filtertagitems.c < prev    next >
C/C++ Source or Header  |  1997-01-27  |  3KB  |  100 lines

  1. /*
  2.     $Id: filtertagitems.c,v 1.2 1997/01/27 00:32:30 ldp Exp $
  3.     $Log: filtertagitems.c,v $
  4.     Revision 1.2  1997/01/27 00:32:30  ldp
  5.     Polish
  6.  
  7.     Revision 1.1  1997/01/08 03:36:13  iaint
  8.     A few more utility.lib functions
  9.  
  10.     Desc: FilterTagItems() - filter an array of TagItems.
  11.     Lang: english
  12. */
  13. #include "utility_intern.h"
  14.  
  15. /*****************************************************************************
  16.  
  17.     NAME */
  18. #include <proto/utility.h>
  19.  
  20.         AROS_LH3(ULONG, FilterTagItems,
  21.  
  22. /*  SYNOPSIS */
  23.         AROS_LHA(struct TagItem *, tagList, A0),
  24.         AROS_LHA(Tag            *, filterArray, A1),
  25.         AROS_LHA(ULONG           , logic, D0),
  26.  
  27. /*  LOCATION */
  28.         struct Library *, UtilityBase, 16, Utility)
  29.  
  30. /*  FUNCTION
  31.         Scans a tag list and removes tag items from the list depending
  32.         upon whether the tag's Tag value is found in an array of tag
  33.         values.
  34.  
  35.         If 'logic' is TAGFILTER_AND, then all the tags that are NOT
  36.         in the array filterArray will be removed from the tagList.
  37.  
  38.         If 'logic' is TAGFILTER_NOT, then all the tags that ARE in
  39.         the array filterArray will be removed from the tagList.
  40.  
  41.         Tags are removed by setting their ti_Tag value to TAG_IGNORE.
  42.  
  43.     INPUTS
  44.         tagList         -   A TagList to filter items from.
  45.         filterArray     -   An array (as described by TagInArray())
  46.                             to determine which tag items are to be
  47.                             removed.
  48.         logic           -   Whether the tags in filterArray are to be
  49.                             included or excluded from the tag list.
  50.  
  51.     RESULT
  52.         The number of valid items left in the resulting filtered list.
  53.  
  54.     NOTES
  55.  
  56.     EXAMPLE
  57.  
  58.     BUGS
  59.  
  60.     SEE ALSO
  61.         TagInArray()
  62.  
  63.     INTERNALS
  64.  
  65.     HISTORY
  66.         29-10-95    digulla automatically created from
  67.                             utility_lib.fd and clib/utility_protos.h
  68.  
  69. *****************************************************************************/
  70. {
  71.     AROS_LIBFUNC_INIT
  72.  
  73.     ULONG valid = 0;
  74.     if(tagList && filterArray)
  75.     {
  76.         struct TagItem *ti;
  77.  
  78.         while((ti = NextTagItem(&tagList)))
  79.         {
  80.             if(logic == TAGFILTER_AND)
  81.             {
  82.                 if(TagInArray(ti->ti_Tag, filterArray))
  83.                     valid++;
  84.                 else
  85.                     ti->ti_Tag = TAG_IGNORE;
  86.             }
  87.             else if(logic == TAGFILTER_NOT)
  88.             {
  89.                 if(TagInArray(ti->ti_Tag, filterArray))
  90.                     ti->ti_Tag = TAG_IGNORE;
  91.                 else
  92.                     valid++;
  93.             }
  94.         }
  95.     }
  96.     return valid;
  97.  
  98.     AROS_LIBFUNC_EXIT
  99. } /* FilterTagItems */
  100.